#include<iostream>
#include<queue>
#include<vector>
#include<utility>
using namespace std;
int mx[105][105];
int mv[4][2] = {{0,1},{1,0},{-1,0},{0,-1}};
int vis[105][105];
typedef struct node{
	int x,y;
	int step;
	vector<pair<int,int> > pre;
}node;
void bfs(){
	node head;
	head.x = 0,head.y = 0;
	head.step = 0;
	head.pre.clear();
	queue<node> q;
	q.push(head);
	while(!q.empty()){
		head = q.front();
		q.pop();
		if(head.x == 4 && head.y == 4){
			head.pre.push_back(make_pair(4,4));
			for(int i = 0;i <= head.step;i++){
				cout << "(" << head.pre[i].first << ", " << head.pre[i].second << ")\n";
			}
			return ;
		}
		for(int i = 0;i < 4;i++){
			int xx = head.x + mv[i][0];
			int yy = head.y + mv[i][1];
			if(xx < 0 || yy < 0 || xx > 4 || yy > 4 || mx[xx][yy] == 1){
				continue;
			}
			if(!vis[xx][yy]){
				vis[xx][yy] = 1;
				node next;
				next.x = xx,next.y = yy,next.step = head.step + 1,next.pre = head.pre;
				next.pre.push_back(make_pair(head.x,head.y));
				q.push(next);
			}
		}
	}
}
int main(){
	for(int i = 0;i < 5;i++){
		for(int j = 0;j < 5;j++){
			cin >> mx[i][j];
		}
	}
	bfs();
}